'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE } = app.Sequelize;

  const UserLike = app.model.define('user_like', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    user_id: INTEGER,
    like_user_id: INTEGER,
    like: INTEGER,
    source: INTEGER,
    super_like: INTEGER,
    extend: STRING(1000),
    create_time: DATE,
    update_time: DATE,
    delete_time: DATE
  });

  UserLike.associate = function() {
    app.model.UserLike.hasOne(app.model.User, {
      as: 'user',
      foreignKey: 'id',
      targetKey: 'user_id'
    });

    app.model.UserLike.hasOne(app.model.User, {
      as: 'userLike',
      foreignKey: 'id',
      targetKey: 'like_user_id'
    });
  }

  return UserLike;
};
